/* 
 * File:   methods.h
 * Author: root
 *
 * Created on 21 mai 2009, 13:46
 */

#ifndef _METHODS_H
#define	_METHODS_H

#include "Torchhead.h"
using namespace Torch;
class Methods {

public:
    
    Methods();
    Methods(const Methods& orig);
    Methods(char * filename);
    virtual ~Methods();
    
    float **arrayToMatrix(float *array);
    Image* arrayToImage(float *array);
    ImageRgb* loadImage(char *fileName);
    float getGrayValue(unsigned char *pixel);
    float **imageToMatrix(ImageRgb *image);
    ImageGray *matrixToImage(float **matrix);
    ImageGray *rgbToGray(ImageRgb *imageIn);
    float getMean(float **matrix, int x, int y);
    void meanFilter(float **matrix);
    float *calculateGradient(Image *image);
    void thresholdBinary(float **matrix,int threshold);
    void erosion(float **matrix);
    void dilatation(float **matrix);
    void setConnect(float **matrix, int x, int y);
    int traceContours(float **matrix);
    void fillSegments(float **matrix);
    char *getName(int pos);
    char *setTitle(char* string,char* prefix);
    void setParam(int iheight,int iwidth);
    void setBack(int ibackpix);
    int getBackColor(Image *image);
    float **firstTraitment(float **matrix);
    float * secondTraitment(float **matrix);
    float **thirdTraitment(float **matrix);
    void finalSegment(float **matrix,ImageRgb *imageIn);
    void localSegment(float **matrix, int **Labels, int label, ImageRgb *imageIn,int id);
    int **labelRegion(float **matrix,int *nb);
    bool newkLabel(int **Labels, int x, int y);
    bool changeLabel(int **Labels, int x, int y,int *lab);
    void applyMask(float **matrix,ImageRgb *imageIn, char *name);
    bool emptyLabel(int **Labels,int lab);
    int *getNumLabels(int **Labels, int label,int *labelout);
    
private:

    char imageFile[50];
    bool verbose;
    int seuil1;
    int seuil2;
    int backpix;
    int height;
    int width;
};

#endif	/* _METHODS_H */

